<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台管理系统-疾病管理</title>

<link rel="stylesheet" type="text/css" href="resources/css/desease.css">
<%@ include  file="../includes/icon.html" %>
</head>
<body>

   <div class="headbar">
        
   </div>
   <div class="linkbar">
     <div>
        <span style="display:inline-block;width:80%;float:left;color:white;line-height:40px;">
            <a class="linkbar_a" href="admin/searchHealthUser">数据手工录入</a> | <a class="linkbar_a" href="admin/queryAutoInput">数据自动录入</a> 
        </span>
        <span style="display:inline-block;width:20%;float:right;color:white;line-height:40px;">
            <a class="linkbar_a" href="doctor/diagnoseBrainTumour" style="float:right;padding-right:30px">在线诊断</a>
        </span>
       </div> 
   </div>
   <div class="body">
       
         <table class="body">
           <tr>
              <td class="nav_list"  valign="top">
                <div> 
                   <dl class="nav_list">
                       <dd class="no-selected" ><a href="admin/searchHealthUser">病人信息</a></dd>
                      <dd class="no-selected" ><a href="admin/queryMedicalCase">疾病实例</a></dd>
                      <dd class="no-selected" ><a href="admin/queryTreatmentMethod">治疗方法</a></dd>
                      <dd class="selected" ><a href="admin/queryDesease">疾病表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryFeature">特征表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryLabSheet">化验单定义</a></dd>
                      <dd class="no-selected" ><a href="admin/queryLabSheetResult">化验单结果</a></dd>
                      <dd class="no-selected" ><a href="admin/queryMedicine">药物表</a></dd>
                      <dd class="no-selected" ><a href="admin/querySystemUser">系统用户</a></dd>
                      <dd class="no-selected" ><a href="admin/queryCity">城市表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryOccupation">职业表</a></dd>
                      <dd class="no-selected" ><a href="admin/queryBodyPart">身体部位表</a></dd>
                   </dl>
                </div>
              </td>
               <td class="content" valign="top">
                  <div class="search_bar"> 
                    <sf:form action="admin/queryDesease" method="POST" modelAttribute="condition"> 
                    <span class="search_condition">
                       <div style="width:100%;margin-left:30px;margin-top:30px;">
                       
                           <font>疾病编号： </font><sf:input path="desease_code"  style="width:150px;"   value ="${condition.desease_code}" />
                           <font>疾病名称： </font><sf:input path="desease_name"  style="width:154px;"   value= "${condition.desease_name}" />
                       </div>
                    </span>
                    <span class="search_button">
                         <input type="submit" class="search_button" value="查询">
                    </span>
                    </sf:form>
                  </div>
                  
                  
                  
                  <script language="javascript"> 
                    var isShown = false;
                    var needShown= ${isAddNewShow};
                    function clickAddDiv()
                    {
                    	if (isShown == false)
                    	{	
                    		showAddDiv();
                    	}
                    	else
                    	{
                    		hideAddDiv();
                    	}
                    }
					function showAddDiv() {

					  d=document.getElementById("add_new_desease");
					  d.style.display="inline-block";
					  
					  isShown =true;
					}
					function hideAddDiv() {

						  d=document.getElementById("add_new_desease");
						  d.style.display="none";
						
						  isShown = false;
				    }
					/*重置，某个疾病的临床特征*/
					function resetClinicValue2(feature_id)
					{
						
						var featureCheckBoxId= 'clinic_add_'+feature_id;
						 
						var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
						
						var currentHiddenValue = document.getElementById('clinic_add').value;
						
						if(currentHiddenValue.length>0&&currentHiddenValue!='|')
						{
							 currentHiddenValue = '|'+currentHiddenValue+'|';
						}
						else
						{
							currentHiddenValue = '|';
						}
					   
						if(featureCheckBoxStatus==true)
						{
						
							if(currentHiddenValue.indexOf('|'+feature_id+'|')<0)
							{
								currentHiddenValue = currentHiddenValue+(feature_id+'|');
							}
						}
						else
						{
							if(currentHiddenValue.indexOf('|'+feature_id+'|')>=0)
							{
								currentHiddenValue = currentHiddenValue.replace(feature_id+'|','');
								if(currentHiddenValue.length == 1)
								{
									currentHiddenValue = '';
								}
							}
						}
						currentHiddenValue = currentHiddenValue.substring(1,currentHiddenValue.length-1);
						document.getElementById('clinic_add').value =currentHiddenValue;
					}
					
					function resetCharacterValue2(id)
					{
						
						var featureCheckBoxId= 'character_add_'+id;
					
						var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
					
						var currentHiddenValue = document.getElementById('character_add').value;
		
						if(featureCheckBoxStatus==true)
						{
							 
							if(currentHiddenValue.charAt(id-1)=='0')
							{
								 
								var temp = currentHiddenValue.substring(0,id-1)+'1'+ currentHiddenValue.substring(id,5);
								currentHiddenValue = temp;
							}
							 
						}
						else
						{
							if(currentHiddenValue.charAt(id-1)=='1')
							{
							 
								var temp = currentHiddenValue.substring(0,id-1)+'0'+ currentHiddenValue.substring(id,5);
								currentHiddenValue = temp;
							}
							 
						}
						document.getElementById('character_add').value =currentHiddenValue;
					}
					
					function resetTreatmentMethodValue2(method_id)
					{
						var featureCheckBoxId= 'treatment_method_add_'+method_id;
						 
						var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
						
						var currentHiddenValue = document.getElementById('treatment_method_add').value;
						
						if(currentHiddenValue.length>0&&currentHiddenValue!='|')
						{
							 currentHiddenValue = '|'+currentHiddenValue+'|';
						}
						else
						{
							currentHiddenValue = '|';
						}
					   // |2| -> |
						if(featureCheckBoxStatus==true)
						{
						
							if(currentHiddenValue.indexOf('|'+method_id+'|')<0)
							{
								currentHiddenValue = currentHiddenValue+(method_id+'|');
							}
						}
						else
						{
							if(currentHiddenValue.indexOf('|'+method_id+'|')>=0)
							{
								currentHiddenValue = currentHiddenValue.replace(method_id+'|','');
								
							}
						}
						currentHiddenValue = currentHiddenValue.substring(1,currentHiddenValue.length-1);
						
						document.getElementById('treatment_method_add').value =currentHiddenValue;
					}
				 </script> 
                  
                  
                  <div class="status_bar">
                     <div style="display:block;float:left">搜索结果：</div>   <div class="add_new_button" onClick="clickAddDiv()" >添加+</div>
                  </div>
                  
                  <div class="add_new_health_user" id="add_new_desease">
                     <sf:form action="admin/addDesease" method="POST" modelAttribute="new_desease"> 
                    <span class="add_new_health_user">
                       <div style="width:100%;margin-left:20px;margin-top:17px;margin-bottom:10px">
				                            <div style="width:100%;margin-left:20px;margin-top:17px;">
		                          			    <font>系统编号： </font><sf:input path="desease_code"  style="width:100px;"    />
					                            <font>疾病名称： </font><sf:input path="desease_name"  style="width:130px;"    />
					                            <font>英文名称： </font><sf:input path="desease_english_name"  style="width:130px;"    />
					                            <font>相关部位： </font><sf:select path="related_part_code"  style="width:120px;" >
					                                                   <c:forEach var = "body_part_item"   items= "${body_part_list}">
					                                                           <sf:option value="${body_part_item.body_part_id}">${body_part_item.body_part_name}</sf:option>
					                                                   </c:forEach>
					                                             </sf:select>
					                        </div>
					                        
					                        <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>临床特征(问诊)： </font><sf:hidden path="clinic_feature"  style="width:150px;"   id="clinic_add" /><br>
						                       <c:forEach var = "clinic_item"   items= "${new_desease.clinic_list}">
						                              <c:if test="${clinic_item.category==1}">
						                                  <input type="checkbox"    ${clinic_item.checked} onclick="resetClinicValue2('${clinic_item.feature_id}')"  id="clinic_add_${clinic_item.feature_id}">${clinic_item.feature_describe_note}</input>      <br> 
						                              </c:if>                  
									           </c:forEach>
									           <br>
									           <font>临床特征(体征)： </font><br>
						                       <c:forEach var = "clinic_item"   items= "${new_desease.clinic_list}">
						                       		  <c:if test="${clinic_item.category==0}">
						                                  <input type="checkbox"    ${clinic_item.checked} onclick="resetClinicValue2('${clinic_item.feature_id}')"  id="clinic_add_${clinic_item.feature_id}">${clinic_item.feature_describe_note}</input>      <br> 
						                              </c:if>                 
									           </c:forEach>
					                        </div>
					                        
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>特性： </font><sf:hidden path="characters"  style="width:150px;"  id="character_add" />
						                       <c:forEach var = "character_item"   items= "${new_desease.charactor_list}">
									               <input type="checkbox"    ${character_item.checkedValue} onclick="resetCharacterValue2(${character_item.id})"  id="character_add_${character_item.id}">${character_item.name}</input>                         
									           </c:forEach>
					                       </div>
					                       
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>治疗方法： </font><sf:hidden path="treatment_methods"  style="width:150px;" id="treatment_method_add" />
						                       <c:forEach var = "treatment_method_item"   items= "${new_desease.treatment_method_list}">
									               <input type="checkbox"    ${treatment_method_item.checked} onclick="resetTreatmentMethodValue2(${treatment_method_item.treatment_method_def_id})"  id="treatment_method_add_${treatment_method_item.treatment_method_def_id}">${treatment_method_item.method_name}</input>                         
									           </c:forEach>
					                       </div>
			                    </div>
                       
                    </span>
                    <span class="add_button">
                          <input type="submit" class="add_button" value="添加" />
                          <div class="add_button">
                              <font style="color:blue;font-size:15px;" onclick="hideAddDiv()" >取消</font>
                          </div>
                    </span>
                    </sf:form>
                  </div>
                  
                  <div class="information" id="information">
                     ${information} 
                  </div>
                  
                  
                  <div class="user_list">
                     <div class="row"> 
                         <span style="width:80px">序号</span>
	                     <span style="width:100px">系统编号</span>
	                     <span style="width:200px">疾病名称</span>
	                     <span style="width:200px">英文名称</span>
	                     <span style="width:100px">发生部位</span>
	                     <span style="width:250px">操作</span>
                     </div>
                     
                      <script language="javascript">
			                    function clickEditDiv(id)
			                    {
			                    	if (document.getElementById("edit_desease"+id).style.display=='none')
			                    	{	
			                    		showEditDiv(id);
			                    	}
			                    	else
			                    	{
			                    		hideEditDiv(id);
			                    	}
			                    }
								function showEditDiv(id) {
			
								  d=document.getElementById("edit_desease"+id);
								  d.style.display="inline-block";
								
								}
								function hideEditDiv(id) {
			
									  d=document.getElementById("edit_desease"+id);
									  d.style.display="none";
								 
							    }
								
								function clickDetailDiv(id)
			                    {
			                    	if (document.getElementById("detail_desease"+id).style.display=='none')
			                    	{	
			                    		showDetailDiv(id);
			                    	}
			                    	else
			                    	{
			                    		hideDetailDiv(id);
			                    	}
			                    }
								function showDetailDiv(id) {
			
								  d=document.getElementById("detail_desease"+id);
								  d.style.display="inline-block";
								  
								}
								function hideDetailDiv(id) {
			
									  d=document.getElementById("detail_desease"+id);
									  d.style.display="none";
									 
							    }
								
								/*重置，某个疾病的临床特征*/
								function resetClinicValue(clinicHiddenId, feature_id)
								{
									
									var featureCheckBoxId= clinicHiddenId+'_'+feature_id;
									 
									var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
								//	alert(featureCheckBoxStatus);
									var currentHiddenValue = document.getElementById(clinicHiddenId).value;
								//	alert(currentHiddenValue);
									if(currentHiddenValue.length>0&&currentHiddenValue!='|')
									{
										 currentHiddenValue = '|'+currentHiddenValue+'|';
									}
									else
									{
										currentHiddenValue = '|';
									}
								   
									if(featureCheckBoxStatus==true)
									{
										
										if(currentHiddenValue.indexOf('|'+feature_id+'|')<0)
										{
										//	alert(2);
											currentHiddenValue = currentHiddenValue+(feature_id+'|');
										}
									}
									else
									{
										
										if(currentHiddenValue.indexOf('|'+feature_id+'|')>=0)
										{
										//	alert(3);
											currentHiddenValue = currentHiddenValue.replace(feature_id+'|','');
										}
									}
									currentHiddenValue = currentHiddenValue.substring(1,currentHiddenValue.length-1);
									document.getElementById(clinicHiddenId).value =currentHiddenValue;
								}
								
								function resetCharacterValue(characterHiddenId, id)
								{
									
									var featureCheckBoxId= characterHiddenId+'_'+id;
								
									var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
								
									var currentHiddenValue = document.getElementById(characterHiddenId).value;
					
									if(featureCheckBoxStatus==true)
									{
										 
										if(currentHiddenValue.charAt(id-1)=='0')
										{
											 
											var temp = currentHiddenValue.substring(0,id-1)+'1'+ currentHiddenValue.substring(id,5);
											currentHiddenValue = temp;
										}
										 
									}
									else
									{
									
										if(currentHiddenValue.charAt(id-1)=='1')
										{
										 
											var temp = currentHiddenValue.substring(0,id-1)+'0'+ currentHiddenValue.substring(id,5);
											currentHiddenValue = temp;
										}
										 
									}
									document.getElementById(characterHiddenId).value =currentHiddenValue;
								}
								
								function resetTreatmentMethodValue(treatmentMethodHiddenId, method_id)
								{
									var featureCheckBoxId= treatmentMethodHiddenId+'_'+method_id;
									 
									var featureCheckBoxStatus = document.getElementById(featureCheckBoxId).checked;
									
									var currentHiddenValue = document.getElementById(treatmentMethodHiddenId).value;
									
									if(currentHiddenValue.length>0&&currentHiddenValue!='|')
									{
										 currentHiddenValue = '|'+currentHiddenValue+'|';
									}
									else
									{
										currentHiddenValue = '|';
									}
								   
									if(featureCheckBoxStatus==true)
									{
									
										if(currentHiddenValue.indexOf('|'+method_id+'|')<0)
										{
											currentHiddenValue = currentHiddenValue+(method_id+'|');
										}
									}
									else
									{
								
										if(currentHiddenValue.indexOf('|'+method_id+'|')>=0)
										{
											
											currentHiddenValue = currentHiddenValue.replace(method_id+'|','');
										}
									}
									currentHiddenValue = currentHiddenValue.substring(1,currentHiddenValue.length-1);
									document.getElementById(treatmentMethodHiddenId).value =currentHiddenValue;
								}
								
				           </script> 
                     
                     <c:forEach var = "desease_item"   items= "${desease_list}"  varStatus="xh">
                     
                         <div class="row">
							     <span style="width:80px">${xh.count}</span>
			                     <span style="width:100px">${desease_item.desease_code}</span>
			                     <span style="width:200px">${desease_item.desease_name}</span>
			                     <span style="width:200px">${desease_item.desease_english_name}</span>			                    
			                     <span style="width:100px">${desease_item.related_part_string}</span>
			                     <span style="width:250px">
			                        <a class="operation"  onClick="clickDetailDiv(${desease_item.desease_def_id})" >详情</a>
			                        <a class="operation"  onClick="clickEditDiv(${desease_item.desease_def_id})" >编辑</a>
			                     </span>  
                    	 </div>
                    	 
                    	 <div class="edit_health_user" id="edit_desease${desease_item.desease_def_id}" style="display:${desease_item.displayName}">
		                   <sf:form action="admin/editDesease" method="POST" modelAttribute="edit_desease"> 
		                    <span class="add_new_health_user">
		                       <sf:input path="desease_def_id" type="hidden" value="${desease_item.desease_def_id}" />
		                         <div style="width:100%;margin-left:20px;margin-top:17px;margin-bottom:10px">
				                            <div style="width:100%;margin-left:20px;margin-top:17px;">
	                          			    <font>系统编号： </font><sf:input path="desease_code"  style="width:100px;"  value="${desease_item.desease_code}"  />
				                            <font>疾病名称： </font><sf:input path="desease_name"  style="width:130px;"  value="${desease_item.desease_name}"  />
				                            <font>英文名称： </font><sf:input path="desease_english_name"  style="width:130px;"  value="${desease_item.desease_english_name}"  />
				                            <font>相关部位： </font><sf:select path="related_part_code"  style="width:120px;" >
				                                                   <c:forEach var = "body_part_item"   items= "${body_part_list}">
				                                                      <c:if test="${body_part_item.body_part_id==desease_item.related_part_code}">
				                                                         <sf:option selected="selected" value="${body_part_item.body_part_id}">${body_part_item.body_part_name}</sf:option>
				                                                      </c:if>
				                                                      <c:if test="${body_part_item.body_part_id!=desease_item.related_part_code}">
				                                                           <sf:option value="${body_part_item.body_part_id}">${body_part_item.body_part_name}</sf:option>
				                                                      </c:if>
				                                                   </c:forEach>
				                                             </sf:select>
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>临床特征(问诊)： </font><br><sf:hidden path="clinic_feature"  style="width:150px;"  value="${desease_item.clinic_feature}"  id="clinic_${desease_item.desease_def_id}" />
						                       <c:forEach var = "clinic_item"   items= "${desease_item.clinic_list}">
						                             <c:if test="${clinic_item.category==1}">
						                                 <input type="checkbox"   ${clinic_item.checked} onclick="resetClinicValue('clinic_${desease_item.desease_def_id}','${clinic_item.feature_id}')"  id="clinic_${desease_item.desease_def_id}_${clinic_item.feature_id}">${clinic_item.feature_describe_note}</input>       <br>   
						                             </c:if>       
									           </c:forEach>
									           
									           <font>临床特征(体征)： </font><br>
						                       <c:forEach var = "clinic_item"   items= "${desease_item.clinic_list}">
						                             <c:if test="${clinic_item.category==0}">
						                                 <input type="checkbox"   ${clinic_item.checked} onclick="resetClinicValue('clinic_${desease_item.desease_def_id}','${clinic_item.feature_id}')"  id="clinic_${desease_item.desease_def_id}_${clinic_item.feature_id}">${clinic_item.feature_describe_note}</input>       <br>   
						                             </c:if>       
									           </c:forEach>
									           
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>特性： </font><sf:hidden path="characters"  style="width:150px;"  value="${desease_item.characters}"  id="character_${desease_item.desease_def_id}" />
						                       <c:forEach var = "character_item"   items= "${desease_item.charactor_list}">
									                 <input type="checkbox"   ${character_item.checkedValue} onclick="resetCharacterValue('character_${desease_item.desease_def_id}',${character_item.id})"  id="character_${desease_item.desease_def_id}_${character_item.id}">${character_item.name}</input>                         
									           </c:forEach>
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>治疗方法： </font><sf:hidden path="treatment_methods"  style="width:150px;"  value="${desease_item.treatment_methods}"  id="treatment_method_${desease_item.desease_def_id}" />
						                       <c:forEach var = "treatment_method_item"   items= "${desease_item.treatment_method_list}">
									                 <input type="checkbox"    ${treatment_method_item.checked} onclick="resetTreatmentMethodValue('treatment_method_${desease_item.desease_def_id}','${treatment_method_item.treatment_method_def_id}')"  id="treatment_method_${desease_item.desease_def_id}_${treatment_method_item.treatment_method_def_id}">${treatment_method_item.method_name}</input>                         
									           </c:forEach>
					                       </div>
			                    </div>
		                    </span>
		                    <span class="add_button">
		                          <input type="submit" class="add_button" value="确认" />
		                          <div class="add_button">
		                              <font style="color:blue;font-size:15px;" onclick="hideEditDiv(${desease_item.desease_def_id})" >取消</font>
		                          </div>
		                    </span>
		                    </sf:form>
		                  </div>
		                  
		                  
		                  <div class="detail_health_user" id="detail_desease${desease_item.desease_def_id}" style="display:none">
		
		                    <span class="add_new_health_user">
		                        <div style="width:100%;margin-left:20px;margin-top:17px;margin-bottom:10px">
				                            <div style="width:100%;margin-left:20px;margin-top:17px;">
	                          			    <font>系统编号： </font><span class="detail_text" style="width:100px;">${desease_item.desease_code}</span><br>
				                            <font>疾病名称： </font><span class="detail_text"  style="width:auto;" >${desease_item.desease_name}</span>
				                            <font>英文名称： </font><span class="detail_text"  style="width:auto" >${desease_item.desease_english_name}</span><br>
				                            <font>相关部位： </font><span class="detail_text"  style="width:120px;">${desease_item.related_part_string}</span>
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           
					                           <font>临床特征(问诊)： </font><br>
						                       <c:forEach var = "clinic_item"   items= "${desease_item.clinic_list}">
						                            <c:if test="${clinic_item.checked=='checked=true' && clinic_item.category ==1}">
						                               <span class="detail_text"  style="margin-left:10px;width:500px;font-weight:bolder;" >${clinic_item.feature_describe_note}</span><br>
						                            </c:if>                
									           </c:forEach>
									           <font>临床特征(体征)： </font><br>
						                       <c:forEach var = "clinic_item"   items= "${desease_item.clinic_list}">
						                            <c:if test="${clinic_item.checked=='checked=true' && clinic_item.category ==0}">
						                               <span class="detail_text"  style="margin-left:10px;width:500px;font-weight:bolder;" >${clinic_item.feature_describe_note}</span><br>
						                            </c:if>                
									           </c:forEach>
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>特性： </font>
						                       <c:forEach var = "character_item"   items= "${desease_item.charactor_list}">
						                             <c:if test="${character_item.checkedValue=='checked=true'}">
						                               <span class="detail_text"  style="width:100px;" >${character_item.name}</span>
						                            </c:if>                           
									           </c:forEach>
					                       </div>
					                       <div style="width:100%;margin-left:20px;margin-top:10px;">
					                           <font>治疗方法： </font>
						                       <c:forEach var = "treatment_method_item"   items= "${desease_item.treatment_method_list}">
									                 <c:if test="${treatment_method_item.checked=='checked=true'}">
						                               <span class="detail_text"  style="width:100px;">${treatment_method_item.method_name}</span>
						                            </c:if>     
									            </c:forEach>
					                       </div>
			                    </div>
		                    </span>
		                    <span class="add_button">
		                          <input type="submit" class="add_button" onclick="hideDetailDiv(${desease_item.desease_def_id})" value="关闭" />
		                    </span>
		                    
		                  </div>
		                  
                     </c:forEach>
                     
                   
                    
                  </div>
              </td>
           </tr>
         </table>
       
   </div>
   <div class="bottom" style="height:200px">
   
   </div>
   
   
</body>
</html>